package behavior;


import sensor.MainColorSensorB;
import sensor.SensorColor;

import lejos.nxt.NXTRegulatedMotor;
import lejos.nxt.remote.RemoteNXT;
import lejos.robotics.subsumption.Behavior;
import motor.barredora;
import motor.carrito;

public class ThrowBlueBall implements Behavior {
	private SensorColor  color;   
    private int cid;
    private NXTRegulatedMotor pala;
    RemoteNXT remote;
    private barredora bar;
    
    public ThrowBlueBall(SensorColor color, carrito carro, NXTRegulatedMotor pala, barredora bar){
    	
    	this.color = color;
	    this.pala  = pala;
	    this.bar = bar;
	   	  
    }

	public boolean takeControl() {
		// TODO Auto-generated method stub
		//.println("Azul");
		
		cid = color.obtenerColor();
		//cid = color.getCurrentColor();
		//cid = 9;
    	if (cid == 0){	    		
    		//.println("Tome control de THROWBLUEBALL: " +Integer.toString(cid));
    		return  true;
    	}
    	return false;
	}

	public void action() {
		// TODO Auto-generated method stub
		//.println("Accion DETECTBALL");
		bar.desactivar();
    	//if(!suppressed) {
    		//if (cid == 0){  //pelota azul    			
    			pala.setSpeed(100);    			
    			pala.setAcceleration(100);    			
    			pala.resetTachoCount();    			
    		//}    		
    		pala.rotate(-60,false);    		
			//Delay.msDelay(2000);
			pala.setAcceleration(100);		
			pala.setSpeed(100);			
			pala.rotate(60,false);		
    	bar.activar();
	}

	public void suppress() {	  
	} 

}
